package auction.model;

import java.util.Date;


public class CategoryItemManyToManyComponent{
	
	private String username;
	private Date dateAdded=new Date();
	
	private ItemManyToManyComponent item;
	private CategoryManyToManyComponent category;
	
	public CategoryItemManyToManyComponent(){
		
	}
	
	public CategoryItemManyToManyComponent(String uname,
											CategoryManyToManyComponent category,
											ItemManyToManyComponent item){
		//Set fields
		this.username=uname;
		this.category=category;
		this.item=item;
		
	}
	
	public boolean equals(Object o){
		if(o!=null && o instanceof CategoryItemManyToManyComponent){
			CategoryItemManyToManyComponent that=(CategoryItemManyToManyComponent)o;
			return this.item.getId().equals(that.getItem().getId()) &&
					this.category.getId().equals(that.getCategory().getId());
		}else{
			return false;
		}
	}
	
	public int hashCode(){
		return item.hashCode()+category.hashCode();
	}
	

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public Date getDateAdded() {
		return dateAdded;
	}

	public void setDateAdded(Date dateAdded) {
		this.dateAdded = dateAdded;
	}

	public CategoryManyToManyComponent getCategory() {
		return category;
	}

	public void setCategory(CategoryManyToManyComponent category) {
		this.category = category;
	}

	public ItemManyToManyComponent getItem() {
		return item;
	}

	public void setItem(ItemManyToManyComponent item) {
		this.item = item;
	}
	
}